package com.acme.bankapp.service.bank;

import com.acme.domain.bank.Client;
import com.acme.domain.bank.Email;
import com.acme.domain.bank.EmailSender;
import com.acme.domain.bank.Queue;

public class EmailService {
	
	private Queue queue;
	private Thread t;
	private EmailSender sender;
	
	public EmailService() {
		queue = new Queue();
		sender = new EmailSender(queue);
		t = new Thread(sender);
		t.start();
	}
	
	public void sendnotificationEmail(Client client, String emailAdress) {
		Email email = new Email(client, emailAdress);
		queue.addEmail(email);
	}
	
	public void close() {
		sender.setTodo(false);
	}

	public EmailSender getSender() {
		return sender;
	}
	
}
